| Server IP : 151.101.66.159 / Your IP : 216.73.216.66 Web Server : Flywheel/5.1.0 System : Linux wordpress 6.12.113+ #1 SMP Thu Oct 22 02:38:20 UTC 2026 x86_64 User : root ( ) PHP Version : 7.4.33.18 Disable Function : disk_free_space,diskfreespace,dl,exec,fpassthru,getmypid,getmyuid,highlight_file,link,opcache_compile_file,opcache_get_configuration,opcache_is_script_cached,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifcontinued,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,phpinfo,popen,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,socket_listen,source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wp-content/plugins/wpmudev-updates/assets/src/js/widget/views/ |
Upload File : |
/* global wdp_analytics_ajax */
import React from 'react'
import moment from 'moment'
import ChartOptions from './overview/chart-options'
import ChartContent from './overview/chart-content'
import Autocomplete from './../components/autocomplete'
import PeriodSelector from './../components/period-selector'
export default class ContentOverview extends React.Component {
constructor(props) {
super(props);
this.state = {
loading: false,
currentOption: this.resetCurrentMetric(),
}
// Register change event.
this.handleOptionChange = this.handleOptionChange.bind(this);
}
/**
* After mounting the component.
*
* @since 4.11.6
*/
componentDidMount() {
this.initMomentLocale();
}
/**
* After mounting the component.
*
* @since 4.11.6
*/
componentDidUpdate(prevProps) {
if (prevProps.filterType !== this.props.filterType) {
this.setState({
currentOption: this.resetCurrentMetric()
})
}
}
/**
* Reset current metrics to first one.
*
* @since 4.11.7
*/
resetCurrentMetric() {
const filterMetrics = this.filterMetrics()
let currentOption = filterMetrics.length > 0 ? filterMetrics[0].key : ''
// Do not show visit time for page stats.
if (this.props.isFiltered && 'page' === this.props.filterType) {
if (filterMetrics.filter(metric => metric.key === 'page_time').length > 0) {
currentOption = 'page_time'
}
}
return currentOption
}
/**
* Filter metrics based on the filter.
*
* @since 4.11.7
*/
filterMetrics() {
// Remove unwanted metrics.
let skipMetrics = ['unique_pageviews']
// Do not show exit rate on full site view.
if (!this.props.isFiltered && !wdp_analytics_ajax.subsite_flag) {
skipMetrics.push('exit_rate')
}
// Do not show visit time for page stats.
if (this.props.isFiltered && 'page' === this.props.filterType) {
skipMetrics.push('visit_time')
} else {
skipMetrics.push('page_time')
}
return this.props.metrics.filter((metric) => !skipMetrics.includes(metric.key))
}
/**
* Setup locale for moment js to use it in chart.
*
* @since 4.11.6
*/
initMomentLocale() {
moment.updateLocale(wdp_analytics_ajax.locale_settings.locale, {
// Inherit anything missing from the default locale.
parentLocale: moment.locale(),
monthsShort: wdp_analytics_ajax.locale_settings.monthsShort,
weekdays: wdp_analytics_ajax.locale_settings.weekdays
});
// Set the locale.
moment.locale(wdp_analytics_ajax.locale_settings.locale);
}
/**
* Handle option change event.
*
* @param {string} option
* @since 4.11.4
*/
handleOptionChange(option) {
this.setState({
currentOption: option
});
}
render() {
let totals = {};
let metrics = this.props.metrics;
let skipMetrics = ['unique_pageviews']
if (typeof this.props.data.totals !== 'undefined') {
totals = this.props.data.totals;
}
// Do not show exit rate on full site view.
if (!this.props.isFiltered && !wdp_analytics_ajax.subsite_flag) {
skipMetrics.push('exit_rate');
}
// Remove unwanted metrics.
metrics = metrics.filter(metric => !skipMetrics.includes(metric.key));
return (
<div
data-pane="overview"
className={`${this.props.currentTab === 'overview' ? 'wpmudui-tab-current ' : ''}wpmudui-tab-content`}
>
<div className="wpmudui-search-form">
<PeriodSelector
type="overview"
period={this.props.period}
/>
<Autocomplete
period={this.props.period.current}
source={this.props.autocomplete}
/>
</div>
<ChartContent
data={this.props.data}
current={this.state.currentOption}
/>
<ChartOptions
totals={totals}
options={metrics}
current={this.state.currentOption}
handleClick={this.handleOptionChange}
/>
</div>
);
}
}